<?php
    if(!$this->session->userdata('logged_in')) {
        redirect('logout');
    } else if($this->session->userdata('role') !== 'admin') {
        redirect('forbidden');
    }
?>
<div id="edit_user_page">
    <div id="edit_user_wrapper">
        <?php echo form_open('user/edit/'.$user['idno'], array('id'=>'edit_user_form')); ?>
            <table id="edit_user_table">
                <tr>
                    <td class="label"><label>ID Number:</label></td>
                    <td class="input_field"><input type="text" value="<?php echo set_value('idno', $user['idno']); ?>" id="fname" name="idno" readonly /></td>
                </tr>
                <tr>
                    <td class="label"><label>First Name:</label></td>
                    <td class="input_field"><input type="text" value="<?php echo set_value('fname', $user['fname']); ?>" id="fname" name="fname" /></td>
                </tr>
                <tr>
                    <td class="label"><label>Middle Name:</label></td>
                    <td class="input_field"><input type="text" value="<?php echo set_value('mname', $user['mname']); ?>" id="mname" name="mname" /></td>
                </tr>
                <tr>
                    <td class="label"><label>Last Name:</label></td>
                    <td class="input_field"><input type="text" value="<?php echo set_value('lname', $user['lname']); ?>" id="lname" name="lname" /></td>
                </tr>
                <tr>
                    <td class="label"><label>Email Address:</label></td>
                    <td class="input_field"><input type="text" value="<?php echo set_value('email', $user['email']); ?>" id="fname" name="email" /></td>
                </tr>
                <tr>
                  <?php
                    if(!is_null($user['course']) || !is_null($user['department'])) {?>
                      <td class="label"><label>Course/Department</label></td>
                      <td class="input_field"><input type="text" value="<?php echo set_value('cd', $user['department'].$user['course']); ?>" id="email" name="cd" /></td>                      
                    <?php }?>
                </tr>
            </table>
            <input name="update" type="submit" value="Update User Details" id="btn_cancel" />
            <input type="button" id="btn_cancel" value="Cancel" onclick="window.location='<?php echo base_url() ?>users';" /><br/>
            <input name="resetpass" type="submit" value="Reset Password" id="btn_cancel" />
        <?php echo form_close(); ?>
    </div>
</div>
